/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gm.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Med EL MOUDDENE
 */
@Entity
@Table(name = "inscription_association")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "InscriptionAssociation.findAll", query = "SELECT i FROM InscriptionAssociation i"),
    @NamedQuery(name = "InscriptionAssociation.findByIdAssociation", query = "SELECT i FROM InscriptionAssociation i WHERE i.inscriptionAssociationPK.idAssociation = :idAssociation"),
    @NamedQuery(name = "InscriptionAssociation.findByIdPersonne", query = "SELECT i FROM InscriptionAssociation i WHERE i.inscriptionAssociationPK.idPersonne = :idPersonne"),
    @NamedQuery(name = "InscriptionAssociation.findByDateDebut", query = "SELECT i FROM InscriptionAssociation i WHERE i.dateDebut = :dateDebut"),
    @NamedQuery(name = "InscriptionAssociation.findByDateFin", query = "SELECT i FROM InscriptionAssociation i WHERE i.dateFin = :dateFin")})
public class InscriptionAssociation implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected InscriptionAssociationPK inscriptionAssociationPK;
    @Column(name = "DATE_DEBUT")
    @Temporal(TemporalType.DATE)
    private Date dateDebut;
    @Column(name = "DATE_FIN")
    @Temporal(TemporalType.DATE)
    private Date dateFin;
    @JoinColumn(name = "ID_ASSOCIATION", referencedColumnName = "ID_ASSOCIATION", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Association association;
    @JoinColumn(name = "ID_PERSONNE", referencedColumnName = "ID_PERSONNE", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Personne personne;

    public InscriptionAssociation() {
    }

    public InscriptionAssociation(InscriptionAssociationPK inscriptionAssociationPK) {
        this.inscriptionAssociationPK = inscriptionAssociationPK;
    }

    public InscriptionAssociation(int idAssociation, int idPersonne) {
        this.inscriptionAssociationPK = new InscriptionAssociationPK(idAssociation, idPersonne);
    }

    public InscriptionAssociationPK getInscriptionAssociationPK() {
        return inscriptionAssociationPK;
    }

    public void setInscriptionAssociationPK(InscriptionAssociationPK inscriptionAssociationPK) {
        this.inscriptionAssociationPK = inscriptionAssociationPK;
    }

    public Date getDateDebut() {
        return dateDebut;
    }

    public void setDateDebut(Date dateDebut) {
        this.dateDebut = dateDebut;
    }

    public Date getDateFin() {
        return dateFin;
    }

    public void setDateFin(Date dateFin) {
        this.dateFin = dateFin;
    }

    public Association getAssociation() {
        return association;
    }

    public void setAssociation(Association association) {
        this.association = association;
    }

    public Personne getPersonne() {
        return personne;
    }

    public void setPersonne(Personne personne) {
        this.personne = personne;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (inscriptionAssociationPK != null ? inscriptionAssociationPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof InscriptionAssociation)) {
            return false;
        }
        InscriptionAssociation other = (InscriptionAssociation) object;
        if ((this.inscriptionAssociationPK == null && other.inscriptionAssociationPK != null) || (this.inscriptionAssociationPK != null && !this.inscriptionAssociationPK.equals(other.inscriptionAssociationPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.gm.entities.InscriptionAssociation[ inscriptionAssociationPK=" + inscriptionAssociationPK + " ]";
    }
    
}
